package routers

import (
	testHandler "NovelBook/controller/test"
	_ "NovelBook/docs"
	"NovelBook/utils/cors"
	"NovelBook/utils/logger"
	"github.com/gin-gonic/gin"
	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

func SetRouter() *gin.Engine {
	r := gin.New()
	r.Use(logger.GinLogger(), logger.GinRecovery(true), cors.Cors()) // 跨域等等

	// 测试
	test := r.Group(baseUrl + "/test")
	{
		test.GET("/ping", testHandler.PingPong)
	}
	r.Use(gin.Recovery())

	// docs-swagger 路由
	r.GET(swaggerUrl, ginSwagger.WrapHandler(swaggerFiles.Handler))

	// Manager 路由
	SetManagerRouter(r)

	// superuser 路由
	SetSuperUserRouter(r)

	// Worker 路由
	SetWorkerRouter(r)

	// Borrower 路由
	SetBorrowerRouter(r)

	// Public 路由
	SetPublicRouters(r)
	//邮箱路由
	SetMailRouters(r)
	// 还要 manager、worker 等仿造上面的进行添加，在设计过程中添加任何需要的接口
	return r
}
